package com.class04.advice;

import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;


/**
 * @ClassDescription:
 * @JdkVersion: 17
 * @Author: yxy
 * @Created: 2023/11/6 8:03
 */
//@Aspect
//@Component
//@Order(10)  //指定一个优先级的值，值越小，优先级级越高！越高的前置前置先执行，后置后执行，最后通知一定会执行
public class TxAdvice {
    @Before("com.class04.pointcut.MyPointCut.pc()")
    public void begin(){
        System.out.println("TxAdvice开启事务前置通知");
    }
    @AfterReturning(value = "com.class04.pointcut.MyPointCut.pc()",returning = "result")
    public void commit(Object result){
        System.out.println("TxAdvice提交事务后置通知");
    }

    @After(value = "com.class04.pointcut.MyPointCut.pc()")
    public void defa(){
        System.out.println("TxAdvice提交事务最后通知");
    }

    @AfterThrowing(value = "com.class04.pointcut.MyPointCut.pc()",throwing = "t")
    public void error(Throwable t){
        System.out.println(t);
    }

}
